package org.actions.admin;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;   
import java.util.Map;

public class AdminPanelAction extends ActionSupport {   
    private String password;

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPassword() {
        return password;
    }
 
    public String loginAsAdmin() {
        if (password.equals("admin")) {
            Map session = ActionContext.getContext().getSession();
            session.put("loginedAsAdmin", "true");
            return SUCCESS;
        }
        return ERROR;
    }
    
    public String logoutAsAdmin() {
        Map session = ActionContext.getContext().getSession();
        session.remove("loginedAsAdmin");
        return SUCCESS;
    }
    
    @Override
    public String execute() throws Exception {   
        return SUCCESS;   
    }

}
